data "alicloud_resource_manager_resource_groups" "rmrg" {
  name_regex = var.resource_group_id
}

data "alicloud_vswitches" "vsws" {
  resource_group_id = data.alicloud_resource_manager_resource_groups.rmrg.groups.0.id
}

# 通过slb 来一个负载均衡，把两个给ip 挂到这一个ip 上面
resource "alicloud_slb_load_balancer" "default" {
  load_balancer_name  = "cloudiac_slb"
  vswitch_id = data.alicloud_vswitches.vsws.vswitches.0.id
  load_balancer_spec = "slb.s2.small"
  address_type = "intranet"
  resource_group_id = data.alicloud_resource_manager_resource_groups.rmrg.groups.0.id
}

module "server_group" {
  source = "../server_group"
  load_balancer_id = alicloud_slb_load_balancer.default.id
}

output "address" {
  value = alicloud_slb_load_balancer.default.address
}
output "ecs" {
  value = module.server_group.ecs
}
